def merge_sort(lst):
    if len(lst) == 1:
        return lst
    middle = len(lst) // 2
    left = merge_sort(lst[:middle])
    right = merge_sort(lst[middle:])
    return merge(left,right)
    
def merge(A,B):
    if len(A) == 0:
        return B;
    if len(B) == 0:
        return A
    if A[0] < B[0]:
        return [A[0]] + merge(A[1:],B)
    else:
        return [B[0]] + merge(A,B[1:])
def merge2(A,B):
    if len(A) == 0:
        return B;
    if len(B) == 0:
        return A
    if A[0] > B[0]:
        return [A[0]] + merge(A[1:],B)
    else:
        return [B[0]] + merge(A,B[1:])

lst = [-9,10,1,5,3,7,8,10]
print(merge_sort(lst))
"""
a = [10,4,2]
b = [5,3,1]
print(merge2(a,b))
"""